using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace GameCore
{
    public class GameState
    {
        protected int i_state;
        public int GAME_STATE_DEF;
        
        public GameState()
        {
            this.GAME_STATE_DEF = -1;
         
        }
        private void MessageEnter(GameTime gameTime)
        {
            i_state = (int)SystemMessage.StateID.Enter;
            this.Enter(gameTime);
        }

        private void MessageUpdate(GameTime gameTime)
        {
            
            i_state = (int)SystemMessage.StateID.Play;
            this.Update(gameTime);
        }

        private void MessagePaint(SpriteBatch g_DC, GameTime gameTime)
        {
            if (i_state != (int)SystemMessage.StateID.Play)
                this.RenderEnter(gameTime, g_DC);
            else
                this.Render(gameTime, g_DC);
        }

        public void StateHandler(GameTime gameTime,SystemMessage.StateMessage message , SpriteBatch graphicsDc)
        {
            if (message == SystemMessage.StateMessage.Enter)
                this.MessageEnter(gameTime);

            else if (message == SystemMessage.StateMessage.Render)
                this.MessagePaint(graphicsDc, gameTime);

            else if (message == SystemMessage.StateMessage.Update)
                this.MessageUpdate(gameTime);
        }
        protected virtual void Enter(GameTime gameTime)
        {
        }
        protected virtual void Update(GameTime gameTime)
        {
        }
        protected virtual void Render(GameTime gameTime, SpriteBatch g_DC)
        {
        }
        protected virtual void RenderEnter(GameTime gameTime, SpriteBatch g_DC)
        {
        }

    }
}
